import React from 'react'
import { NavBar } from 'antd-mobile';
import PropTypes from 'prop-types';
import './index.scss'

function Header({props,rightContent,rightTitle,rightClick,title,classNames}) {
  // console.log(props)
  return (
    <>
      <header className={`header news-com-header ${classNames}`}>
        <NavBar
          className="news_chat_header"
          mode="light"
          leftContent={<img alt='' src='/images/Return.png' />}
          onLeftClick={() => {
            console.log(props)
            props.history.goBack()
          }}
        rightContent={rightContent? <img alt='' src={ rightContent } onClick={rightClick}/> : <span onClick={rightClick} className="am-navbar-right_spanInfo">{rightTitle}</span> }
        >{title}</NavBar>
      </header>
    </>
  )
}

Header.propTypes = {
  // 父元素的props, 用作返回
  props: PropTypes.object.isRequired,
  // 右边的图标的地址url
  rightContent: PropTypes.string,
  // 右边的点击事件
  rightClick: PropTypes.func,
  // title
  title: PropTypes.string,
  // 类名, 用来在父组件中写样式
  classNames: PropTypes.string
}

export default Header